<!DOCTYPE html>
<html>
<head>
<title>SMART - Dashboard</title>
<jsp:include page="../include/head.jsp" />
</head>
<body>
   <div class="wrapper">
      <!-- 导航区 -->
      <jsp:include page="../include/topnav.jsp" />
      <!-- 左侧菜单区 -->
      <jsp:include page="../include/menu.jsp" />
      <!-- 右侧边栏 -->
      <jsp:include page="../include/right.jsp" />
      <!-- Main section-->
      <section>
         <!-- Page content-->
         <div class="content-wrapper">
            <div class="content-heading">编辑用户</div>
            <div class="panel panel-default">
            	<div class="panel-body">
            		<jsp:include page="../include/info.jsp" />
					<form role="form" action="admin/editAdmin" method="post" class="form-horizontal">
					<c:if test="${theUser!=null}">
					<input type="hidden" name="id" value="${theUser.id}" />
					</c:if>
					<div class="form-group">
						<label for="name" class="col-sm-2 control-label">登录ID</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="username" name="username" value="${theUser.username}" />
						</div>
					</div>
					<div class="form-group">
						<label for="name" class="col-sm-2 control-label">姓名</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="name" name="name" value="${theUser.name}" />
						</div>
					</div>
					
					<div class="form-group">
						<label for="teams" class="col-sm-2 control-label">所属团队</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="teams" name="teams" value="${theUser.teams}" />
						</div>
					</div>
					
					<div class="form-group">
						<label for="team" class="col-sm-2 control-label">角色</label>
						<div class="col-sm-10" id="roleList">
							<input type="hidden" id="roles" name="roles" value="${theUser.roles}" />
							<label class="checkbox-inline">
							  	<input type="checkbox" id="role-ROLE_SUPER_ADMIN" value="ROLE_SUPER_ADMIN" <c:if test="${theUser.hasRole('ROLE_SUPER_ADMIN')}">checked</c:if> />超级管理员
							</label>
							<label class="checkbox-inline">
							  	<input type="checkbox" id="role-ROLE_SALES_ADMIN" value="ROLE_SALES_ADMIN" <c:if test="${theUser.hasRole('ROLE_SALES_ADMIN')}">checked</c:if> />电销管理员
							</label>
							<label class="checkbox-inline">
							  	<input type="checkbox" id="role-ROLE_SALES" value="ROLE_SALES" <c:if test="${theUser.hasRole('ROLE_SALES')}">checked</c:if> />电销
							</label>
							<label class="checkbox-inline">
							  	<input type="checkbox" id="role-ROLE_OP_ADMIN" value="ROLE_OP_ADMIN" <c:if test="${theUser.hasRole('ROLE_OP_ADMIN')}">checked</c:if> />运营管理员
							</label>
							<label class="checkbox-inline">
							  	<input type="checkbox" id="role-ROLE_OP" value="ROLE_OP" <c:if test="${theUser.hasRole('ROLE_OP')}">checked</c:if> />运营
							</label>
						</div>
					</div>
					
					<div class="form-group">
						<label for="description" class="col-sm-2 control-label">&nbsp;</label>
						<div class="col-sm-10">
							<button type="submit" class="btn btn-primary">提交</button>
							<a href="admin/listAdmin" class="btn btn-primary">返回</a>
						</div>
					</div>
				</form>
			 	</div>
			</div>
         </div>
      </section>
      <jsp:include page="../include/footer.jsp" />
   </div>
   <jsp:include page="../include/script.jsp" />
</body>
</html>
<script>
$('#mainMenu li').removeClass('active');
$('#menuListAdmin').addClass('active');

$('#roleList input').click(function(){
	var val = [];
	$('#roleList input:checked').each(function(item){
		val.push($(this).val());
	});
	$('#roles').val(val.join(','));
});
</script>